$(document).ready(function() {

  var trueOrFalse = true;

  $().button('toggle');

  $('form').submit(function(){
  
     $('#article').find("p,h1,h2,h3,h4,h5,td,caption").removeAttr("contenteditable");
  
     $(this).find('textarea').text( $('#article').html() );
  });

  $('form button[data-toggle=button]').click(function(){
     $('#article').find("p,h1,h2,h3,h4,h5,td,caption").attr('contenteditable', trueOrFalse)
     //$('#article').attr('contenteditable', trueOrFalse)
     //$('#article').find("p,h1,h2,h3,h4,h5,td,caption").attr('contenteditable', !trueOrFalse)
     
     trueOrFalse = !trueOrFalse;
  });

  $('#article').bind('DOMNodeInserted DOMNodeRemoved', function(event) {
     if (event.type == 'DOMNodeInserted') {
      //alert('Content added! Current content:' + '\n\n' + this.innerHTML);
    } else {
      //alert('Content removed! Current content:' + '\n\n' + this.innerHTML);
    }
    
    $('#article').find('*').removeAttr("style");
    
  });

});